<!--
  - Copyright (c) 2018.
  - 北京九思金信科技有限公司对该文件内容保留所有权利。
  - 未经许可，不得私自拷贝、传播、发布、引用该文件内容，违者将被追究法律责任。
  -->
  <template>
  <div class="infoSearch_box">
    <div class="infoSearch_title">
      <div class="search_box">
        <img src="@/pages/mobile/assets/img/Back@3x.png" @click="returnHistory" alt />
        <!-- <input type="text" placeholder="搜索你感兴趣的应用" maxlength="20" v-model="aaaa"> -->
        <input
          type="text"
          placeholder="搜索"
          maxlength="20"
          v-model="searchInfoItem"
        />
      </div>
      <i @click="returnHistory">取消</i>
    </div>
    <scroll class="infoSearch_list_box">
      <div class="infoSearch_list">
        <div
          class="infoSearch_list_item"
          v-for="item in searchlist"
          :key="item.id"
        >
          <dir class="infoSearch_list_item_img">
            <i
              :class="{
                i_active: item.messageStatus != 'UNREAD' ? false : true
              }"
            ></i>
            <img
              :class="{
                isOpacity: item.messageStatus != 'UNREAD' ? true : false
              }"
              :src="item.img"
              alt
            />
          </dir>
          <div class="infoSearch_list_item_info">
            <div class="infoSearch_list_item_info_title">
              <span
                :class="{
                  isOpacity: item.messageStatus != 'UNREAD' ? true : false
                }"
                >{{ item.messageTitle }}</span
              >
              <em
                :class="{
                  isOpacity: item.messageStatus != 'UNREAD' ? true : false
                }"
                >{{ item.creationTs | dateFormat("yyyy/MM/dd hh:mm:ss") }}
                <x-icon
                  class="icon_arrows"
                  type="ios-arrow-forward"
                  size="30"
                ></x-icon>
              </em>
            </div>
            <div class="infoSearch_list_item_info_content">
              <p
                :class="{
                  isOpacity: item.messageStatus != 'UNREAD' ? true : false
                }"
              >
                {{ item.messageContent }}
              </p>
            </div>
          </div>
        </div>
        <div
          v-if="!searchlist.length && searchInfoItem"
          class="infoSearch_none_list"
        >
          没有搜索到任何关于“{{ searchInfoItem }}”的消息
        </div>
        <div
          v-show="!searchlist.length && !searchInfoItem"
          class="infoSearch_none_list"
        >
          搜索信息
        </div>
      </div>
    </scroll>
  </div>
</template>
  
  <script>
import Scroll from "@/pages/mobile/components/JoysScroll/JoysScroll";
import { myDOM } from "@/pages/mobile/assets/js/utils.js";
export default {
  name: "infoSearch",
  components: {
    Scroll
  },
  props: {
    typeId: {
      type: String,
      default: ""
    }
  },
  data () {
    return {
      aaaa: "",
      searchInfoItem: "",
      searchlist: []
    };
  },
  methods: {
    searchInfoList () {
      // debugger
      this.$axios({
        url: "/joys-rest/joys-admin/message/page",
        method: "get",
        headers: {
          "AUTH-TOKEN": localStorage.getItem("AUTH-TOKEN")
        },
        params: {
          messageContent: this.searchInfoItem,
          messageTypeId: this.typeId,
          pageIndex: 1,
          pageSize: 1000
        }
      })
        .then(res => {
          this.searchlist = res.data.rows;
        })
        .catch(error => {
          console.log(error);
        });
    },
    queryImg (id) {
      return (
        this.$baseUrl + "/joys-rest/joys-file/file/browse/one2one/" +
        id +
        "?AUTH-TOKEN=" +
        localStorage.getItem("AUTH-TOKEN")
      );
    },
    returnHistory () {
      this.$emit("childEvent");
      this.searchlist = "";
    }
  },
  created () {
    // debugger
    // 节流
    this.$watch(
      "searchInfoItem",
      myDOM.debounce(newQuery => {
        this.searchInfoList();
      }, 300)
    );
  }
};
</script>
  
  <style scoped lang="less">
.infoSearch_box {
  position: fixed;
  top: 0rem;
  bottom: 0.1rem;
  width: 100%;
  height: 100%;
  z-index: 800;
  overflow: hidden;
  background: #ffffff;
  .infoSearch_title {
    height: 0.44rem;
    width: 100%;
    background: #ffffff;
    box-shadow: inset 0 -1px 0 0 rgba(207, 207, 207, 0.2);
    position: relative;
    overflow: hidden;
    .search_box {
      position: absolute;
      top: 0rem;
      left: 0rem;
      width: 100%;
      height: 0.44rem;
      line-height: 0.44rem;
      img {
        width: 0.2rem;
        position: absolute;
        left: 0.085rem;
        top: 0.12rem;
      }
      input {
        padding-left: 0.1rem;
        height: 0.32rem;
        background: rgba(141, 141, 141, 0.05);
        font-family: Regular;
        font-size: 0.14rem;
        color: #001616;
        letter-spacing: -0.34px;
        line-height: 0.14rem;
        margin-top: -0.05rem;
        margin-left: 0.36rem;
        width: 100%;
      }
      input::placeholder {
        font-family: PingFangSC-Regular;
        font-size: 14px;
        color: #909090;
        letter-spacing: -0.34px;
        line-height: 14px;
      }
    }
    i {
      display: block;
      height: 0.43rem;
      width: 0.63rem;
      line-height: 0.44rem;
      text-align: center;
      font-family: Regular;
      font-size: 0.14rem;
      color: #001616;
      letter-spacing: -0.34px;
      position: absolute;
      top: 0rem;
      right: 0rem;
      background: #ffffff;
    }
  }
  .infoSearch_list_box {
    margin-top: 0.44rem;
    height: 100%;
    overflow: hidden;
    // margin-bottom: -0.88rem;
    .infoSearch_list {
      background: #ffffff;
      .infoSearch_list_item {
        background: #ffffff;
        overflow: hidden;
        // height: 0.68rem;
        // margin-left: 0.18rem;
        // padding-right: 0.16rem;

        // border-bottom: 1px rgba(207, 207, 207, 0.2) solid;
        .infoSearch_list_item_img {
          float: left;
          width: 0.64rem;
          height: 0.8rem;
          border-radius: 0.18rem;
          display: flex;
          align-items: center;
          i {
            height: 12px;
            width: 12px;
            border-radius: 50%;
            display: inline-block;
            margin-left: 0.06rem;
          }
          .i_active {
            background: #E9B55C;
          }
          img {
            width: 0.32rem;
            height: 0.32rem;
            margin: auto;
            border-radius: 50%;
          }
          .isOpacity {
            opacity: 0.6;
          }
        }
        .infoSearch_list_item_info {
          // width: 100%;
          // width: 2.87rem;

          margin-left: 0.48rem;
          height: 0.8rem;
          box-shadow: inset 0 -1px 0 0 rgba(207, 207, 207, 0.2);
          // background-color: red;
          // float: left;
          .infoSearch_list_item_info_title {
            overflow: hidden;
            padding-bottom: 0.04rem;
            // height: 0.24rem;
            span {
              float: left;
              margin-top: 0.12rem;
              font-family: Mediums;
              font-size: 0.15rem;
              color: #001616;
              letter-spacing: -0.36px;
              height: 0.2rem;
              line-height: 0.2rem;
              width: 60%;
              white-space: nowrap;
              text-overflow: ellipsis;
              overflow: hidden;
            }
            .isOpacity {
              opacity: 0.6;
            }
            em {
              float: right;
              font-family: Regular;
              font-size: 0.13rem;
              color: #adadad;
              letter-spacing: -0.36px;
              text-align: right;
              line-height: 0.13rem;
              margin-top: 0.12rem;
              display: flex;
              align-items: center;
              .vux-x-icon {
                fill: #d1d1d6;
                height: 0.16rem;
                overflow: hidden;
              }
            }
          }
          .infoSearch_list_item_info_content {
            overflow: hidden;
            height: 0.32rem;
            margin-right: 0.16rem;
            p {
              float: left;
              font-family: Regular;
              font-size: 0.13rem;
              color: #8e8e8e;
              letter-spacing: -0.31px;
              text-align: justify;
              line-height: 0.16rem;
              overflow: hidden;
            }
            .isOpacity {
              opacity: 0.6;
              overflow: hidden;

              text-overflow: ellipsis;

              display: -webkit-box;

              -webkit-box-orient: vertical;

              -webkit-line-clamp: 2;
            }
          }
        }
        // .infoSearch_list_item_img {
        //   float: left;
        //   width: 0.24rem;
        //   height: 100%;
        //   // background: red;
        //   display: flex;
        //   justify-content: center;
        //   align-items: center;
        //   margin-right: 0.16rem;
        //   img {
        //     height: 0.24rem;
        //   }
        // }
        // .infoSearch_list_item_info {
        //   // float: left;
        //   p {
        //     padding-top: 0.06rem;
        //     font-family: Regular;
        //     font-size: 0.15rem;
        //     color: #535353;
        //     letter-spacing: -0.36px;
        //     line-height: 0.2rem;
        //     width: 60%;
        //     white-space: nowrap;
        //     text-overflow: ellipsis;
        //     overflow: hidden;
        //   }
        //   .stylefont {
        //     padding-top: 0.04rem;
        //     font-family: Regular;
        //     font-size: 0.12rem;
        //     color: #8e8e8e;
        //     letter-spacing: -0.29px;
        //     text-align: justify;
        //     line-height: 0.16rem;

        //     overflow: hidden;
        //     text-overflow: ellipsis;
        //     display: -webkit-box;
        //     -webkit-line-clamp: 2;
        //     -webkit-box-orient: vertical;
        //   }
        // }
      }
    }
    .infoSearch_list::after {
      content: "";
      height: 0.44rem;
      display: block;
      width: 100%;
    }
  }

  .infoSearch_none_list {
    font-family: Regular;
    font-size: 0.13rem;
    color: rgba(0, 22, 22, 0.8);
    letter-spacing: 0;
    text-align: center;
    margin-top: 30%;
  }
}
.slide-enter-active,
.slide-leave-active {
  transition: all 0.3s ease;
}
.slide-enter,
.slide-leave-to {
  opacity: 0;
  transform: translate3d(0, 5%, 0);
}
</style>
